#include "cfg.h"
#include "LogManagement.h"

#include <time.h>
#include <assert.h>

namespace EngineLib {

	void LogManagement::OpenFile(void)
	{
	}

	void LogManagement::CloseFile(void)
	{
	}

	void LogManagement::LogFile(char *msg)
	{
	}

	void LogManagement::LogFile(unsigned int code)
	{
	}

	void LogManagement::StartUp(void)
	{
	}

	void LogManagement::ShutDown(void)
	{
	}

	void LogManagement::switchChannel(unsigned int channal)
	{
		LogManagement::_channal = channal;
	}

	void LogManagement::Log(char *msg, unsigned int channal)
	{
		assert(channal);
		if (LogManagement::_channal & channal) {
			time_t t;
			time(&t);
			//printf(ctime(&t));
			printf("\t%s\n", msg);
		}
		
#ifdef LOG_FILE
		//LogManagement::LogFile(ctime(&t));
		LogManagement::LogFile(msg);
#endif
	}

	void LogManagement::Error(unsigned int code)
	{
			time_t t;
			time(&t);
			//printf(ctime(&t));
			printf("Error Code:%d\n", code);

#ifdef LOG_FILE
		//LogManagement::LogFile(ctime(&t));
		LogManagement::LogFile(code);
#endif
	}

	unsigned int LogManagement::_channal = 0xFFFFFFFF;
	FILE *LogManagement::_file = 0;
}